<?

/* CACTO OMAR CARPINTEYRO :: C3 v2.0*/

function func_cat_GuionTipoPregunta ($table,$inputname,$id_row,$st_row,$where,$tipo,$order,$Validar,$echo) {

    $mssql_02   = "SELECT ".$id_row.",".$st_row." FROM ".$table." ".$where." ".$order;
    if($echo == 1) {
      //HELP::fun_Echo ("title","color","texto");
      fun_Echo("func_cat_GuionTipoPregunta","red",$mssql_02);
    }
    if(strstr($st_row,"as")) {
         $st_rowArray = explode("as",$st_row);
         $st_rowArrayCount = count($st_rowArray);
         $st_row      = str_replace(" ","",$st_rowArray[$st_rowArrayCount-1]);
    }
    // ***************************
    // SELECT
    // ***************************
    if($tipo == "select") {
        $result_02  = mssql_query($mssql_02);
        if ($row_02  = mssql_fetch_array($result_02)) {
            $CAT_select = "<select name=\"".$inputname."\">\n";
            $CAT_select .= "<option value=\"0\">- Seleccione ----------------&gt;</option>\n";
            do {
                if($Validar <> 0) {
                   if($row_02[$id_row] == $Validar) {
                     $MarcaCheck = "selected";
                   }else{
                     $MarcaCheck = "";
                   }
                }
                $CAT_select .= "<option value=\"".$row_02[$id_row]."\" ".$MarcaCheck.">".urldecode($row_02[$st_row])."</option>\n";
            }while($row_02 = mssql_fetch_array($result_02));
            $CAT_select .= "</select>";
        }else{
            $CAT_select ='<select name="'.$inputname.'"><option value="0">Deshabilitado</option></select>';
        }
    // ***************************
    // RADIO
    // ***************************
    }else if($tipo == "radio") {
        $result_02  = mssql_query($mssql_02);
        if ($row_02  = mssql_fetch_array($result_02)) {
            $CAT_select = "";
            do {
                if($Validar <> 0) {
                   if($row_02[$id_row] == $Validar) {
                     $MarcaCheck = "checked";
                   }else{
                     $MarcaCheck = "";
                   }
                }else if($row_02[$id_row]==1) {
                    $MarcaCheck = "checked";
                }
                $CAT_select .= "<input type=\"radio\" name=\"".$inputname."\" value=\"".$row_02[$id_row]."\" ".$MarcaCheck.">".$row_02[$st_row]."<br>\n";
                $MarcaCheck = "";
            }while($row_02 = mssql_fetch_array($result_02));
        }else{
            $CAT_select = 'Deshabilidato';
        }
    }else{
        $CAT_select = "Input no especificado";
    }
    
    return $CAT_select;
    
}

?>
